package com.ytjj.qmyx.supplychain.mapper;

import com.ytjj.qmyx.supplychain.common.model.request.ReissueLogisticsRequest;
import com.ytjj.qmyx.supplychain.common.model.response.ReissueLogisticsResponse;
import com.ytjj.qmyx.supplychain.mapper.entity.YxOrders;
import com.ytjj.qmyx.supplychain.mapper.entity.YxReissueLogistics;
import org.apache.ibatis.annotations.Param;
import tk.mybatis.mapper.common.Mapper;

import java.util.Date;
import java.util.List;

public interface ReissueLogisticsMapper extends Mapper<YxReissueLogistics> {

    List<ReissueLogisticsResponse> selectList(ReissueLogisticsRequest reissueLogisticsRequest);

    Integer updateLogistics(ReissueLogisticsRequest reissueLogisticsRequest);

    Integer refuseStatus(Integer id);

    /**
     * 获得最新的补单信息
     */
    List<YxReissueLogistics> getLatestByChildOrderNo(@Param("childOrderNos") List<String> childOrderNos);

    /**
     * 修改补单信息
     */
    Integer updateReissueLogistics(@Param("reissueLogisticsId") Integer reissueLogisticsId,@Param("recoveryOrderNo")String recoveryOrderNo,@Param("shopId")String shopId,@Param("childOrderNo")String childOrderNo);

    /**
     * 修改补单状态
     * @param id
     * @return
     */
    Integer updateDeleteStatus(@Param("id") Integer id,@Param("childOrderNo")String childOrderNo);

    /**
     * 查询创建时间在day天内
     * 处理成功上传了补单物流的补单记录
     */
    List<YxReissueLogistics> queryReissueLogisticsList(Integer day);

    /**
     * 更新未签收的补单物流信息
     */
    int updateReissueLogisticsExpress(YxReissueLogistics logistic);

    /**
     * 修改已签收的补单信息为已完结
     */
    int  updateReissueLogisticsFished(YxReissueLogistics logistic);

    /**
     * 修改补单信息为是否已完结
     */
    int  updateReissueLogisticsIsFished(@Param("reissueLogisticsId") Integer reissueLogisticsId,@Param("finishStatus") Integer finishStatus,
                                      @Param("reissueStatus")Integer reissueStatus,@Param("finishTime")Date finishTime);

    Integer refuseStatusAndReason(@Param("id")Integer id,@Param("reason")String reason);

    Integer refuseListStatus(@Param("reissueLogisticsIdList")List<Integer> reissueLogisticsIdList, @Param("reason") String reason);

    List<YxReissueLogistics> selectByChildOrderNoList(@Param("childOrderNoList") List<String> childOrderNoList);

    /**
     * 获取已签收超过day天的补单订单
     */
    List<YxOrders> getOrderByReplacementCheck(Integer day);

    /**
     * 修改补单理由
     * @param reissueLogisticsId
     * @param logisticsReason
     * @return
     */
    int  updateLogisticsReason(@Param("reissueLogisticsId") String reissueLogisticsId,@Param("logisticsReason") String logisticsReason,@Param("childOrderNo") String childOrderNo);


}
